﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMarker : MonoBehaviour {

	Animator m_Animator;

	[SerializeField] private Transform boy;
	[SerializeField] private Transform bird;

	Vector3 scaleBoy = new Vector3(.7f,.7f, .7f);
	Vector3 scaleBird = new Vector3(.5f ,.5f, .5f);

	Transform target;
	bool m_MoveOver = true;

	float fadeTime = 1;


	private void Awake() {
		m_Animator = GetComponent<Animator>();
		target = boy;
	}

	private void Update() {

		if (!m_MoveOver) {
			fadeTime += Time.deltaTime;
			transform.Translate((target.position - transform.position) * Time.deltaTime * 30 * fadeTime);

			if (Vector3.Distance(transform.position, target.position) < .3f) {
				transform.position = target.position;
				m_MoveOver = true;
				fadeTime = 0;
			}

		} else {
			transform.position = target.position;
		}



	}

	public void ShowMarker(bool visible, int index) {
		m_Animator.SetBool("Visible", visible);
		if(index == 0) {
			target = boy;
			transform.localScale = scaleBoy;
		} else {
			target = bird;
			transform.localScale = scaleBird;
		}

		m_MoveOver = false;
	}

}
